/*
-------------------------------------------------------------------
BIE is Copyright 2001-2004 Brunswick Corp.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/bie_license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
 */
/*
 * RSAEncrypt.java
 *
 * Created on January 6, 2003, 4:05 PM
 */

package tests.jd;

import java.security.*;

/**
 *
 * @author  jdepons
 */
public class RSAEncrypt {
    
    /** Creates a new instance of RSAEncrypt */
    public RSAEncrypt() {
    
        KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
        keyGen.initialize(1024);
        KeyPair key = keyGen.generateKeyPair();

        Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
        System.out.println("\n" + cipher.getProvider().getInfo());
        System.out.println("\nStart Encryption");
        cipher.init(Cipher.ENCRYPT_MODE, key.getPublic());
        byte[] cipherText = cipher.doFinal(plainText);
        System.out.println("Finish Encryption: ");
        System.out.println(new String(cipherText, "UTF8"));           
    }
    
}
